home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Object = "{72D18DD4-0DA7-11D2-8E21-00B404C10000}#2.1#0"; "ODCBOLST.OCX" Begin VB.Form frmLineStyle BorderStyle = 3 'Fixed Dialog Caption = "Owner Draw Combo Box Client Draw Demo" ClientHeight = 2850 ClientLeft = 3945 ClientTop = 1740 ClientWidth = 5790 Icon = "frmLineStyle.frx":0000 LinkTopic = "Form1" MaxButton = 0 'False MinButton = 0 'False ScaleHeight = 2850 ScaleWidth = 5790 ShowInTaskbar = 0 'False Begin VB.PictureBox picTexture AutoRedraw = -1 'True AutoSize = -1 'True BorderStyle = 0 'None Height = 1920 Index = 4 Left = 4440 Picture = "frmLineStyle.frx":0442 ScaleHeight = 1920 ScaleWidth = 1920 TabIndex = 10 Tag = "Dark Sky" Top = 4440 Visible = 0 'False Width = 1920 End Begin VB.PictureBox picTexture AutoRedraw = -1 'True AutoSize = -1 'True BorderStyle = 0 'None Height = 1920 Index = 3 Left = 4080 Picture = "frmLineStyle.frx":0E9F ScaleHeight = 1920 ScaleWidth = 1920 TabIndex = 9 Tag = "Liquid Metal" Top = 4020 Visible = 0 'False Width = 1920 End Begin VB.PictureBox picTexture AutoRedraw = -1 'True AutoSize = -1 'True BorderStyle = 0 'None Height = 1920 Index = 2 Left = 3600 Picture = "frmLineStyle.frx":16E6 ScaleHeight = 1920 ScaleWidth = 1920 TabIndex = 8 Tag = "Soap Stone" Top = 3660 Visible = 0 'False Width = 1920 End Begin VB.PictureBox picTexture AutoRedraw = -1 'True AutoSize = -1 'True BorderStyle = 0 'None Height = 1920 Index = 1 Left = 3240 Picture = "frmLineStyle.frx":1BDB ScaleHeight = 1920 ScaleWidth = 1920 TabIndex = 7 Tag = "Green Blur" Top = 3300 Visible = 0 'False Width = 1920 End Begin VB.PictureBox picTexture AutoRedraw = -1 'True AutoSize = -1 'True BorderStyle = 0 'None Height = 1920 Index = 0 Left = 3180 Picture = "frmLineStyle.frx":21C4 ScaleHeight = 1920 ScaleWidth = 1920 TabIndex = 6 Tag = "Pink Granite" Top = 2940 Visible = 0 'False Width = 1920 End Begin ODCboLst.OwnerDrawComboList cboBackTexture Height = 360 Left = 3060 TabIndex = 5 Top = 360 Width = 2715 _ExtentX = 4789 _ExtentY = 635 BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = -2147483630 ClientDraw = 2 End Begin ODCboLst.OwnerDrawComboList cboLineDash Height = 360 Left = 120 TabIndex = 3 Top = 1200 Width = 2715 _ExtentX = 4789 _ExtentY = 635 BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = -2147483630 ClientDraw = 2 End Begin ODCboLst.OwnerDrawComboList cboLineStyle Height = 360 Left = 120 TabIndex = 0 Top = 360 Width = 2715 _ExtentX = 4789 _ExtentY = 635 BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty ForeColor = -2147483630 ClientDraw = 2 End Begin VB.Image imgTexture BorderStyle = 1 'Fixed Single Height = 1935 Left = 3060 Top = 780 Width = 1935 End Begin VB.Label lblBackTexture Caption = "&Texture:" BeginProperty Font Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 195 Left = 3060 TabIndex = 4 Top = 120 Width = 2775 End Begin VB.Label lblDashed Caption = "&Dashed:" BeginProperty Font Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 120 TabIndex = 2 Top = 960 Width = 2655 End Begin VB.Label lblLineStyle Caption = "&Style:" BeginProperty Font Name = "Tahoma" Size = 8.25 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 255 Left = 120 TabIndex = 1 Top = 120 Width = 2655 End Attribute VB_Name = "frmLineStyle" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Option Explicit Private Declare Function GetFocus Lib "user32" () As Long Private Sub cboBackTexture_Click() Dim lIndex As Long lIndex = cboBackTexture.ItemData(cboBackTexture.ListIndex) If (lIndex = -1) Then Set imgTexture.Picture = Nothing Else Set imgTexture.Picture = picTexture(lIndex).Picture End If End Sub Private Sub cboBackTexture_DrawItem(Index As Long, hdc As Long, bSelected As Boolean, bEnabled As Boolean, LeftPixels As Long, TopPixels As Long, RightPixels As Long, BottomPixels As Long, hFntOld As Long) Dim tR As RECT Dim hBrush As Long Dim lY As Long Dim sText As String Dim iIndex As Long Dim tFR As RECT tR.left = LeftPixels tR.tOp = TopPixels tR.Bottom = BottomPixels tR.Right = RightPixels If (bSelected) Then hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)) Else hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)) End If FillRect hdc, tR, hBrush DeleteObject hBrush If (GetFocus() = cboBackTexture.hwnd) And bSelected Then DrawFocusRect hdc, tR End If If (Index <> -1) Then If (cboBackTexture.ItemOverLine(Index)) Then DrawLine hdc, tR.left, tR.Right, tR.tOp, 1 End If ' Blit the texture at 2,2->96,height-4: iIndex = cboBackTexture.ItemData(Index) If (iIndex > -1) Then BitBlt hdc, tR.left + 2, tR.tOp + 2, 64, (tR.Bottom - tR.tOp - 4), picTexture(iIndex).hdc, 0, 0, SRCCOPY Else tFR.left = tR.left + 2: tFR.tOp = tR.tOp + 2: tFR.Right = tFR.left + 64: tFR.Bottom = tFR.tOp + (tR.Bottom - tR.tOp - 4) DrawFocusRect hdc, tFR End If tR.left = tR.left + 68 ' Draw the text: SetBkMode hdc, TRANSPARENT sText = cboBackTexture.List(Index) DrawText hdc, sText, -1, tR, DT_LEFT End If End Sub Private Sub cboBackTexture_MeasureItem(Index As Long, WidthPixels As Long, HeightPixels As Long) WidthPixels = cboBackTexture.Width \ Screen.TwipsPerPixelX HeightPixels = (cboBackTexture.Height * 2) \ Screen.TwipsPerPixelY End Sub Private Sub cboLineDash_DrawItem(Index As Long, hdc As Long, bSelected As Boolean, bEnabled As Boolean, LeftPixels As Long, TopPixels As Long, RightPixels As Long, BottomPixels As Long, hFntOld As Long) Dim tR As RECT Dim hBrush As Long Dim lY As Long tR.left = LeftPixels tR.tOp = TopPixels tR.Bottom = BottomPixels tR.Right = RightPixels If (bSelected) Then hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)) Else hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)) End If FillRect hdc, tR, hBrush DeleteObject hBrush If (GetFocus() = cboLineDash.hwnd) And bSelected Then DrawFocusRect hdc, tR End If If (Index <> -1) Then lY = tR.tOp + (tR.Bottom - tR.tOp) \ 2 DrawLine hdc, tR.left + 4, tR.Right - 4, lY, 1, cboLineDash.ItemData(Index) End If End Sub Private Sub cboLineDash_MeasureItem(Index As Long, WidthPixels As Long, HeightPixels As Long) WidthPixels = cboLineStyle.Width \ Screen.TwipsPerPixelX HeightPixels = cboLineStyle.Height \ Screen.TwipsPerPixelY End Sub Private Sub cboLineStyle_DrawItem(Index As Long, hdc As Long, bSelected As Boolean, bEnabled As Boolean, LeftPixels As Long, TopPixels As Long, RightPixels As Long, BottomPixels As Long, hFntOld As Long) Dim tR As RECT Dim tTXR As RECT Dim sText As String Dim hBrush As Long Dim iLineWidth As Long Dim iLineStyle As Long Dim lY As Long SetBkMode hdc, TRANSPARENT tR.left = LeftPixels tR.tOp = TopPixels tR.Bottom = BottomPixels tR.Right = RightPixels If (bSelected) Then hBrush = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)) Else hBrush = CreateSolidBrush(GetSysColor(COLOR_WINDOW)) End If FillRect hdc, tR, hBrush DeleteObject hBrush If (GetFocus() = cboLineStyle.hwnd) And bSelected Then DrawFocusRect hdc, tR End If If (Index <> -1) Then iLineWidth = cboLineStyle.ItemExtraData(Index) iLineStyle = cboLineStyle.ItemData(Index) sText = cboLineStyle.List(Index) LSet tTXR = tR tTXR.left = tTXR.left + 4 DrawText hdc, sText, -1, tTXR, DT_CALCRECT DrawText hdc, sText, -1, tTXR, DT_LEFT tR.left = 24 tR.Right = tR.Right - 4 Select Case iLineStyle Case 1 ' single line: lY = tR.tOp + (tR.Bottom - tR.tOp) \ 2 DrawLine hdc, tR.left, tR.Right, lY, (iLineWidth \ 100) Case 2 ' two thin lines: lY = tR.tOp + (tR.Bottom - tR.tOp) \ 2 lY = lY - 1 DrawLine hdc, tR.left, tR.Right, lY, 1 lY = lY + 1 DrawLine hdc, tR.left, tR.Right, lY, 1 Case 3 ' thin then thick: lY = tR.tOp + (tR.Bottom - tR.tOp) \ 2 lY = lY - 2 DrawLine hdc, tR.left, tR.Right, lY, 1 lY = lY + 3 DrawLine hdc, tR.left, tR.Right, lY, 2 Case 4 ' thick then thin: lY = tR.tOp + (tR.Bottom - tR.tOp) \ 2 lY = lY - 2 DrawLine hdc, tR.left, tR.Right, lY, 2 lY = lY + 2 DrawLine hdc, tR.left, tR.Right, lY, 1 Case 5 ' thin-thick-thin lY = tR.tOp + (tR.Bottom - tR.tOp) \ 2 lY = lY - 3 DrawLine hdc, tR.left, tR.Right, lY, 1 lY = lY + 3 DrawLine hdc, tR.left, tR.Right, lY, 2 lY = lY + 2 DrawLine hdc, tR.left, tR.Right, lY, 1 End Select End If End Sub Private Function DrawLine(ByVal hdc As Long, ByVal lXStart As Long, ByVal lXEnd As Long, ByVal lY As Long, ByVal lWidth As Long, Optional ByVal lStyle As Long = PS_SOLID) Dim hPen As Long Dim hPenOld As Long Dim tP As POINTAPI hPen = CreatePen(lStyle, lWidth, GetSysColor(COLOR_WINDOWTEXT)) hPenOld = SelectObject(hdc, hPen) MoveToEx hdc, lXStart, lY, tP LineTo hdc, lXEnd, lY SelectObject hdc, hPenOld DeleteObject hPen End Function Private Sub cboLineStyle_MeasureItem(Index As Long, WidthPixels As Long, HeightPixels As Long) WidthPixels = cboLineStyle.Width \ Screen.TwipsPerPixelX HeightPixels = cboLineStyle.Height \ Screen.TwipsPerPixelY End Sub Private Sub Form_Load() Dim i As Long With cboLineStyle .AddItemAndData " ", , , , , 1, 25 .AddItemAndData " ", , , , , 1, 50 .AddItemAndData " ", , , , , 1, 75 .AddItemAndData "1", , , , , 1, 100 .AddItemAndData "1 ", , , , , 1, 150 .AddItemAndData "2 ", , , , , 1, 225 .AddItemAndData "3", , , , , 1, 300 .AddItemAndData "4 ", , , , , 1, 450 .AddItemAndData "6", , , , , 1, 600 .AddItemAndData "3", , , , , 2, 100 .AddItemAndData "4 ", , , , , 3, 150 .AddItemAndData "4 ", , , , , 4, 150 .AddItemAndData "6", , , , , 5, 150 .ListIndex = 0 End With With cboLineDash .AddItemAndData "", , , , , PS_SOLID .AddItemAndData "", , , , , PS_DASHDOT .AddItemAndData "", , , , , PS_DASHDOTDOT .AddItemAndData "", , , , , PS_DOT .ListIndex = 0 End With For i = picTexture.LBound To picTexture.UBound cboBackTexture.AddItemAndData picTexture(i).Tag, , , , , i Next i cboBackTexture.AddItemAndData "None", , , , , -1 cboBackTexture.ItemOverLine(cboBackTexture.NewIndex) = True cboBackTexture.ListIndex = 0 End Sub